﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MediatR;
using W.Device.Domain.DTO;
using W.Purchase.Domain;
using W.Purchase.Read.API.AppLication.Command;
using Microsoft.AspNetCore.Authorization;
using W.Purchase.Domain.DTO;
namespace W.Purchase.Read.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class VendorController : ControllerBase
    {
        private readonly IMediator mediator;

        public VendorController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 分页显示
        /// </summary>
        /// <param name="command"></param>
        /// <returns>返回集合</returns>
        [HttpPost]
        public async Task<List<VendorDTO>> VendorShow(VendorShowCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 分页显示
        /// </summary>
        /// <param name="command"></param>
        /// <returns>返回集合</returns>
        [HttpPost]
        public async Task<List<VendorType>> VendorTypeBang(VendorTypeCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 供应商名称显示
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<List<Vendor>>> VendorNameShow()
        {
            return await mediator.Send(new VendorNameShowCommand());
        }
        /// <summary>
        /// 供应商反填
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<Vendor>> VendorShowFan(VendorShowFanCommand command)
        {
            return await mediator.Send(command);
        }
    }
}
